﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace Hack.Pdb2Mdb
{
    public class PdbReader
    {
        public PdbReader(Stream reader, int pageSize)
        {
            this.pageSize = pageSize;
            this.reader = reader;
        }

        public void Seek(int page, int offset)
        {
            reader.Seek(page * pageSize + offset, SeekOrigin.Begin);
        }

        public void Read(byte[] bytes, int offset, int count)
        {
            reader.Read(bytes, offset, count);
        }

        public int PagesFromSize(int size)
        {
            return (size + pageSize - 1) / (pageSize);
        }

        public int PageSize
        {
            get { return pageSize; }
        }

        public readonly int pageSize;
        public readonly Stream reader;
    }
}
